#region Summary

// 
// Owner : JackieHan 
// 
// Solution : LearnSolution 
// 
// Project : JackieHan.NHiberante.SessionManage
// 
// File : HttpSessionStorage.cs
// 
// CopyRight : Copyright © 2010-2011 Skomart Corporation, All Rights Reserved 
// 
// Summary : Http Session 管理
// 
// History : 
//			2010-09-28 13:29:25	    Create 
// 

#endregion

#region Using

using System;
using System.Web;
using NHibernate;

#endregion

namespace JackieHan.NHiberante.SessionManage
{
    /// <summary> 
    /// Http Session 管理
    /// </summary>
    public class HttpSessionStorage : ISessionStorage
    {
        #region ISessionStorage Members

        public ISession Get()
        {
            return (ISession) HttpContext.Current.Items[Config.HttpSessionSourceItemName];
        }

        public void Set(ISession value)
        {
            if (value != null)
            {
                HttpContext.Current.Items.Add(Config.HttpSessionSourceItemName, value);
            }
            else
            {
                HttpContext.Current.Items.Remove(Config.HttpSessionSourceItemName);
            }
        }

        #endregion
    }
}